import Vue from 'vue';
import viewnav from 'components/viewnav';
import btndel from 'components/btndel';
import btnfiledel from 'components/btnfiledel';
import helpinfo from 'components/helpinfo';
import CcDialog from 'components/cc-dialog';
import CcLoading from 'components/cc-loading';

import inputDate from 'components/form/inputdate';
import inputDatetime from 'components/form/inputdatetime';
import inputEditDatetime from 'components/form/inputeditdatetime';
import inputTime from 'components/form/inputtime';
import inputTimerange from 'components/form/inputtimerange';
import InputDatePicker from 'components/form/inputdatepicker';
import InputDateRange from 'components/form/inputdaterange';
import InputTabs from 'components/form/inputtabs';
import selectTime from 'components/form/selecttime';
import SelectSearch from 'components/form/selectsearch';
import inputColor from 'components/form/inputcolor';
import SubUpload from 'components/form/subupload';
import InputShuttle from 'components/form/inputshuttle';
import CascadeItem from 'components/form/cascadeitem';
import TableTopBtns from 'components/tabletopbtns';
import TableOptBtns from 'components/tableoptbtns';
import VuePreview from 'vue-preview';
import CcTable from 'components/quasar/cc-table';
import CcTd from 'components/quasar/cc-td';
import CcBtn from 'components/quasar/cc-btn';
import VueViewer from 'v-viewer';
import 'viewerjs/dist/viewer.css';

Vue.use(VuePreview, {
  mainClass: 'pswp--minimal--dark',
  barsSize: { top: 0, bottom: 0 },
  captionEl: false,
  fullscreenEl: false,
  shareEl: false,
  bgOpacity: 0.85,
  tapToClose: true,
  tapToToggleControls: false,
});

Vue.component('QTable', CcTable);
Vue.component('QTd', CcTd);
Vue.component('CcBtn', CcBtn);
Vue.component('viewNav', viewnav);
Vue.component('btnDel', btndel);
Vue.component('btnFileDel', btnfiledel);
Vue.component('helpInfo', helpinfo);
Vue.component('CcDialog', CcDialog);
Vue.component('CcLoading', CcLoading);
Vue.component('TableTopBtns', TableTopBtns);
Vue.component('TableOptBtns', TableOptBtns);

Vue.component('inputDate', inputDate);
Vue.component('inputDatetime', inputDatetime);
Vue.component('InputDatePicker', InputDatePicker);
Vue.component('InputDateRange', InputDateRange);
Vue.component('InputTabs', InputTabs);
Vue.component('InputShuttle', InputShuttle);
Vue.component('CascadeItem', CascadeItem);
Vue.component('SubUpload', SubUpload);
Vue.component('inputEditDatetime', inputEditDatetime);
Vue.component('inputTime', inputTime);
Vue.component('selectTime', selectTime);
Vue.component('SelectSearch', SelectSearch);
Vue.component('inputTimerange', inputTimerange);
Vue.component('inputColor', inputColor);

Vue.use(VueViewer, {
  defaultOptions: {
    inline: true,
    button: true,
    navbar: false,
    title: false,
    toolbar: true,
    tooltip: false,
    movable: true,
    zoomable: true,
    rotatable: true,
    scalable: true,
    transition: true,
    fullscreen: true,
    keyboard: false,
    zIndex: 99999
  }
});

Vue.directive('auth', (el, { value }, vnode) => {
  if (!vnode.context.$store.getters['Rule/confirmAuth'](value)) {
    setTimeout(() => {
      el.style.display = 'none';
    }, 0);
  }
});

Vue.directive('choosing', (el, { expression, value }) => {
  if (value || expression === undefined) {
    el.classList.add('v-choosing');
  } else {
    el.classList.remove('v-choosing');
  }
});
